var validatorPhone = function(rule, value, callback) {
  if (value === '') {
    callback(new Error('请输入负责人手机号码'))
  } else if (!/^1\d{10}$/.test(value)) {
    callback(new Error('请输入正确的手机号码'))
  } else {
    callback()
  }
}
var validatorName15 = function(rule, value, callback) {
  var reg = /^[+-]?(0|([1-9]\d*))(\.\d+)?$/ // 小数点左边最高8位，小数点右边最多4位
  if (value === '') {
    callback(new Error('请输入管理费率'))
  } else if (!reg.test(value)) {
    callback(new Error('请输入正确的管理费率'))
  } else if (value < 0) {
    callback(new Error('管理费率不能小于0'))
  } else {
    callback()
  }
}
var validatorBankAccount = function(rule, value, callback) {
  if (value === '') {
    callback(new Error('请输入银行账号'))
  } else if (!/^([1-9]{1})(\d{15}|\d{16}|\d{18})$/.test(value)) {
    callback(new Error('请输入正确的银行账号'))
  } else {
    callback()
  }
}
const validate = {
  name1: [
    {
      required: true,
      message: '请输入企业名称',
      trigger: 'change'
    }
  ],
  name2: [
    {
      required: true,
      message: '请输入统一信用代码',
      trigger: 'change'
    }
  ],
  name3: [
    {
      required: true,
      message: '请输入开户银行',
      trigger: 'change'
    }
  ],
  name4: [
    {
      required: true,
      message: '请输入公司地址',
      trigger: 'change'
    }
  ],
  name5: [
    {
      required: true,
      trigger: 'change',
      validator: validatorBankAccount
    }
  ],
  name6: [
    {
      required: true,
      message: '请输入签约主体',
      trigger: 'change'
    }
  ],
  name7: [
    {
      required: true,
      message: '请选择合同签约时间',
      trigger: 'change'
    }
  ],
  name8: [
    {
      required: true,
      message: '请选择合同到期时间',
      trigger: 'change'
    }
  ],
  name9: [
    {
      required: true,
      message: '请上传企业营业执照',
      trigger: 'change'
    }
  ],
  name11: [
    {
      required: true,
      message: '请输入负责人',
      trigger: 'change'
    }
  ],
  name12: [
    {
      required: true,
      trigger: 'change',
      validator: validatorPhone
    },
    { type: 'number', message: '请输入正确的手机号码' }
  ],
  // name13: [
  //   {
  //     required: true,
  //     message: '请输入登录密码',
  //     trigger: 'change'
  //   }
  // ],
  name14: [
    {
      required: true,
      message: '请输入充值账号',
      trigger: 'change'
    }
  ],
  name15: [{ required: true, trigger: 'change', validator: validatorName15 }],
  name16: [
    {
      required: true,
      message: '请输入账户名称',
      trigger: 'change'
    }
  ],
  name17: [
    {
      required: true,
      message: '请输入平台开户银行',
      trigger: 'change'
    }
  ]
}
export default validate
